package com.news.model;

public class Likes {
    private int likeId;
    private int userId; // 点赞用户ID
    private Integer newsId; // 关联新闻ID，如果点赞的是新闻
    private Integer commentId; // 关联评论ID，如果点赞的是评论
    private long createdAt;
    private boolean isActive;
    public Likes(int userId, Integer newsId, Integer commentId) {
        this.userId = userId;
        this.newsId = newsId;
        this.commentId = commentId;
        this.createdAt = System.currentTimeMillis(); // 或者使用数据库的DEFAULT CURRENT_TIMESTAMP

        // 这里可以添加验证逻辑来确保newsId和commentId中只有一个被设置
        if (newsId != null && commentId != null) {
            throw new IllegalArgumentException("newsId and commentId cannot both be set");
        }
    }

    public Likes() {

    }

    public int getLikeId() {
        return likeId;
    }

    public void setLikeId(int likeId) {
        this.likeId = likeId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Integer getNewsId() {
        return newsId;
    }

    public void setNewsId(Integer newsId) {
        this.newsId = newsId;
    }

    public Integer getCommentId() {
        return commentId;
    }

    public void setCommentId(Integer commentId) {
        this.commentId = commentId;
    }

    public long getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(long createdAt) {
        this.createdAt = createdAt;
    }

    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean active) {
        isActive = active;
    }

// 注意：由于newsId和commentId是二选1的，你可能需要添加一些业务逻辑来确保它们的使用正确性
}